package cn.rocky.prepare;

import java.util.Arrays;

public class singleNumber {

    public int singleNumber(int[] nums) {
        int ans = 0;
        for (int i = 0; i < 32; ++i) {
            int total = 0;
            for (int num: nums) {
                total += ((num >> i) & 1);
            }
            if (total % 3 != 0) {
                ans |= (1 << i);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        singleNumber singleNumber = new singleNumber();
        System.out.println(singleNumber.singleNumber(new int[]{1, 2, 2, 2}));
    }
}
